package com.zeroup.matrix.appplication;

import android.app.Activity;
import android.app.Application;


import com.blankj.utilcode.util.DeviceUtils;
import com.blankj.utilcode.util.StringUtils;
import com.bytedance.sdk.open.aweme.authorize.model.Authorization;
import com.bytedance.sdk.open.aweme.commonbase.net.a;
import com.bytedance.sdk.open.aweme.init.DouYinOpenSDKConfig;
import com.bytedance.sdk.open.douyin.DouYinOpenApiFactory;
import com.bytedance.sdk.open.douyin.DouYinOpenConfig;
import com.bytedance.sdk.open.douyin.api.DouYinOpenApi;
import com.zeroup.matrix.MainActivity;
import com.zeroup.matrix.bean.UserInfo;
import com.zeroup.matrix.utile.PreferencesManager;

import org.kymjs.kjframe.KJDB;

import java.util.List;

public class ZeroneAppliction extends Application {

    public static String HOST = "101.200.13.82:1688";
//    public static String HOST = "www.gldhcmkj.cn";

//    public static String apiUrl = "http://"+HOST+":8080/";
    public static String apiUrl = "http://"+HOST+"/api/";

    String clientkey = "awbz0c65m7qcxvr0"; // 需要到开发者网站申请


    @Override
    public void onCreate() {
        super.onCreate();
        DouYinOpenSDKConfig.Builder builder = new DouYinOpenSDKConfig.Builder();
        builder.clientKey(clientkey)
                .context(this)
                .networkService(new a());
        DouYinOpenApiFactory.initConfig(builder.build());
//        PreferencesManager.setContext(this);
//        DouYinOpenApiFactory.init(new DouYinOpenConfig(clientkey));
    }


    public static void toDouyin(Activity activity){
        DouYinOpenApi douyinOpenApi = DouYinOpenApiFactory.create(activity);
        Authorization.Request request = new Authorization.Request();
        request.scope = "user_info,aweme.share,aweme.forward,aweme.share";                          // 用户授权时必选权限
        request.state = DeviceUtils.getUniqueDeviceId();                  //                // 用于保持请求和回调的状态，授权请求后原样带回给第三方。
        request.callerLocalEntry = MainActivity.class.getName();  // 第三方指定自定义的回调类 Activity
        request.optionalScope1 = "aweme.share,aweme.forward,aweme.share,item.comment";
        douyinOpenApi.authorize(request);
    }



}
